package com.wiley.service;

import java.net.MalformedURLException;

import org.openqa.selenium.By;

import com.wiley.publicMethod.BasePage;
import com.wiley.publicMethod.LoggerControler;

import io.appium.java_client.android.AndroidDriver;

public class FeedbackPage extends BasePage {
	
	LoggerControler log;

	/**
	 * 页面元素
	 */
	//我的
	public static final By mine_item_loc = By.id(BaseId + "mine_item");
	
	//意见反馈
	public static final By feedback_tv_loc = By.id(BaseId + "feedback_tv");
	
	//设置 setting_btn
	public static final By setting_btn_loc = By.id(BaseId + "setting_btn");
	
	//个人
	public static final By personality_loc = By.name("个人");
	
	//设置中的意见反馈 tv_feed
	public static final By setting_tv_feed_loc = By.id(BaseId + "tv_feed");
	
	//意见反馈输入框 et_feed
	public static final By et_feed_loc = By.id(BaseId + "et_feed");
	
	//完成
	public static final By finish_loc = By.name("完成");
	
	//转到上一层级
	public static final By back_loc = By.name("转到上一层级");
	
	/**
	 * 操作方法
	 */
	//点击我的
	public void clickMineItem(){
		this.clickEle(mine_item_loc);
	}
	
	/**
	 * 1、我的->意见反馈；2、设置->意见反馈
	 */
	public void clickFeedback(){
		super.swipeToUp(500);
		this.clickEle(feedback_tv_loc);
	}
	
	public void clickFeedbackBySetting(){
		this.clickEle(setting_btn_loc);
		if(this.isElementPresent(personality_loc)){
			super.swipeToUp(1000);
			this.clickEle(setting_tv_feed_loc);
		}else{
			this.clickEle(setting_tv_feed_loc);
		}
	}
	
	public void inputFeedbackContent(String content){
		this.sendKeys(et_feed_loc, content);
		//this.clickEle(finish_loc);
		this.clickEle(back_loc);
	}
	
	
	/**
	 * 业务封装
	 * @throws MalformedURLException 
	 * @throws InterruptedException 
	 */
	public void feedback(Class name) throws MalformedURLException {
		log = this.MyLogger(name);
		AndroidDriver driver = super.SetDriver();
		this.clickMineItem();
		this.clickFeedback();
		this.inputFeedbackContent("哈哈哈");
		
		this.clickFeedbackBySetting();
		this.inputFeedbackContent("呵呵呵");
		log.info("该case测试通过！");
	}
}
